home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 2
/
Amiga Tools 2.iso
/
tools
/
mg
/
rexx
/
findtag.mg
< prev
next >
Wrap
Text File
|
1995-03-09
|
2KB
|
65 lines
/*
* findtag searches the buffer *TAGS* to find a tag that matches it's
* argument, and then goes to the line it tags. If *TAGS* doesn't exist,
* it will prompt the user for a file name (default tags), and load that
* file into the buffer.
*
* The format of the *TAGS* buffer is the same as the tags file, which is
* what is created by the ctags program to be found on Fish Disk #197.
*
* Note that we may want to use etags instead of ctags....
*/
options results
options failat 2
signal on failure
/* Find a tag to search for */
if arg(1, 'Exists') then tag = arg(1)
else do
'rexx-request "Find tag? "'
tag = result
if rc ~= 0 then exit 0
end
/* get our old buffer name */
'rexx-buffer tagbuffer'
bufname = tagbuffer.1
/* Make sure we've got the tags buffer built, oh yes, oh yeah */
'switch-to-buffer *TAGS*'
'rexx-buffer tagbuffer'
if tagbuffer.3 = 1 then do
'rexx-request "Tag file (tags)? "'
if rc = 0 then 'insert-file' file
else 'insert-file tags'
end
/* Find the line for the tag we're looking for */
'beginning-of-buffer'
'search-forward "\^Q\^J'tag'\^Q\^I"'
if rc ~= 0 then do
'rexx-display "Can''t find tag' tag'"'
signal failure
end
'rexx-line'
parse var result '09'x file '09'x '/^' line '$/'
'find-file' file
if rc ~= 0 then do
'rexx-display "Can''t find file' file'"'
signal failure
end
'beginning-of-buffer'
'search-forward "'line'"'
if rc ~= 0 then do
'rexx-display "Can''t find tag line"'
signal failure
end
exit 0
failure:
'switch-to-buffer "'bufname'"'
exit 1